<template>
	<view class="content">
		<u-navbar title="员工管理" height="88rpx" :placeholder='true' left-icon-color="#fff"
			titleStyle='color:#fff;font-size:32rpx' left-icon-size="32rpx" bg-color="#FF594D" :autoBack="true">
		</u-navbar>

		<view class="grid">
			<view class="grid_content">
				<view class="grid_wrap">
					<template v-for="item in serveList">
						<view class="grid_item" @click="navigateTo(item.url)">
							<image :src="item.src" mode=""></image>
							{{item.text}}
						</view>
					</template>
					<view class="grid_item" @click="empVerification">
						<image src="../../static/images/spell-page/Frame@2x (10).png" mode=""></image>
						核销商品
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		verification,
		verificationNumber
	} from '../../../api/employee.js'
	export default {
		data() {
			return {
				titleStyle: {
					color: '#fff',
				},

				serveList: [{
						text: '主产品开单',
						src: '../../static/images/spell-page/Frame@2x.png',
						url: '/pages_spell/pages/main-product/main-product'
					}, {
						text: '开单记录',
						src: '../../static/images/spell-page/Frame@2x (1).png',
						url: '/pages_spell/pages/billing-record/billing-record'
					}, {
						text: '退货记录',
						src: '../../static/images/spell-page/Frame@2x (2).png',
						url: '/pages_spell/pages/sales-return/sales-return'
					}, {
						text: '回款记录',
						src: '../../static/images/spell-page/Frame@2x (3).png',
						url: '/pages_spell/pages/buy-back/buy-back'
					}, {
						text: '会员管理',
						src: '../../static/images/spell-page/Frame@2x (4).png',
						url: '/pages_spell/pages/member-list/member-list'
					}, {
						text: '发展中客户',
						src: '../../static/images/spell-page/Frame@2x (5).png',
						url: '/pages_spell/pages/developing-client/developing-client'
					}, {
						text: '客户转移',
						src: '../../static/images/spell-page/Frame@2x (6).png',
						url: '/pages_spell/pages/customer-switching/customer-switching'
					}, {
						text: '发卡券',
						src: '../../static/images/spell-page/Frame@2x (7).png',
						url: '/pages_spell/pages/send-coupon/send-coupon'
					}, {
						text: '发红包',
						src: '../../static/images/spell-page/Frame@2x (8).png',
						url: '/pages_spell/pages/red-packet/red-packet'
					}, {
						text: '发积分',
						src: '../../static/images/spell-page/Frame@2x (9).png',
						url: '/pages_spell/pages/integral/integral'
					}, {
						text: '余额收款明细',
						src: '../../static/images/spell-page/Frame@2x (10).png',
						url: '/pages_spell/pages/balance-record/balance-record'
					},
					// {
					// 	text: '核销商品',
					// 	src: '../../static/images/spell-page/Frame@2x (10).png',
					// 	url: '/pages_spell/pages/balance-record/balance-record'
					// },
				]
			}
		},
		methods: {
			empVerification() {
				uni.scanCode({
					success: (res) => {
						console.log(res);
						if (isNaN(res.result)) {
							this.verification(res.result)
						} else {
							this.verificationNumber(res.result)
						}
					}
				})
			},
			async verificationNumber(number) {
				const res = await verificationNumber(number)
				console.log(res);
				if (res.code != 200) {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
					return
				}
				uni.showToast({
					title: res.msg
				})
			},
			async verification(verificationCode) {
				const res = await verification(verificationCode)
				console.log(res);
				if (res.code != 200) {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
					return
				}
				uni.showToast({
					title: res.msg
				})
			},

			navigateTo(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		background-color: #f3f3f3;
		min-height: 100vh;
		// padding-bottom: 140rpx;
		// // #ifdef MP
		// padding-bottom: 260rpx;
		// // #endif

		.grid {
			background-color: #fff;
			margin-bottom: 20rpx;

			.grid_content {
				padding: 33rpx 30rpx 0;

				.grid_title {
					display: flex;
					padding: 0 7rpx 20rpx;
					justify-content: space-between;
					align-items: center;

					.grid_title_left {
						font-size: 26rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 800;
						color: #000000;
					}

					.grid_title_right {
						font-size: 26rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						color: #777777;
						display: flex;
						align-items: center;

						image {
							margin-left: 36rpx;
							width: 17rpx;
							height: 32rpx;
						}

					}
				}

				.grid_wrap {
					display: flex;
					flex-wrap: wrap;
					// justify-content: space-between;

					.grid_item {
						width: 126rpx;
						height: 114rpx;
						display: flex;
						flex-direction: column;
						justify-content: space-between;
						align-items: center;
						font-size: 26rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						color: #777777;
						margin: 0 60rpx 42rpx 0;
						white-space: nowrap;
						position: relative;

						image {
							width: 68rpx;
							height: 68rpx;
						}

						.reminder {
							position: absolute;
							width: 39rpx;
							height: 28rpx;
							background-color: #FF2525;
							border-radius: 99rpx;
							font-size: 20rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 800;
							color: #FFFFFF;
							text-align: center;
							line-height: 28rpx;
							right: 20rpx;
						}
					}

					.grid_item:nth-of-type(4n+0) {
						margin-right: 0;
					}
				}
			}
		}
	}
</style>